package by.alex.dzeshko.lastfmsimple.http.request;

import by.alex.dzeshko.lastfmsimple.R;
import by.alex.dzeshko.lastfmsimple.app.ContextHolder;
import android.os.Parcel;
import android.os.Parcelable;

public class LastFmRequest implements Parcelable{

	private final Type mType;

	private final Method mMethod;

	public static enum Type {
		GET, POST
	}
	
	public static enum Method {
		SEARCHARTIST, SEARCHALBUM, SEARCHTTRACK
	}
	
	private final String mQuery;
	
	private final int mLimit;
	
	private final String mApiKey = ContextHolder.getInstance().getContext().getString(R.string.api_key);
		
	public static class Builder {
		
		private Type mType;

		private Method mMethod;
		
		private String mQuery;
		
		private int mLimit;
		
		public Builder setType(Type type){
			this.mType = type;
			return this;
		}
		
		public Builder setMethod(Method apiMethod){
			this.mMethod = apiMethod;
			return this;
		}
		
		public Builder setQuery(String query){
			this.mQuery = query;
			return this;
		}
		public Builder setLimit(int limit){
			this.mLimit = limit;
			return this;
		}
		
		public LastFmRequest build(){
			return new LastFmRequest(this);
		}
	}
	
	public LastFmRequest(Builder builder) {
		this.mType = builder.mType;
		this.mMethod = builder.mMethod;
		this.mQuery = builder.mQuery;
		this.mLimit = builder.mLimit;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		dest.writeInt(mLimit);
		dest.writeString(mQuery);
		dest.writeValue(mMethod);
		dest.writeValue(mType);
		
	}

}
